package com.hae.shop.member.api;

import com.hae.shop.common.base.Response;
import com.hae.shop.member.model.reqDto.*;
import com.hae.shop.member.model.respDto.UserLoginRespDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;


@Api //可以使用tags指定名称
public interface MemberService {

    @ApiOperation(value = "会员应用服务接口")
    @GetMapping("/getWechatInfoByMember")
    String getWechatInfoByMember();

    @ApiOperation(value = "会员用户注册信息接口")
    @PostMapping("/register")
    Response<Boolean> register(@RequestBody @Valid UserRegistryReqDto userRegistryReqDto,
                               @RequestParam("registCode")
                               @NotNull(message = "验证码不能为null！")
                               @NotBlank(message = "验证码不能为空！") String registCode);

    @ApiOperation(value = "根据手机号查询是否已经存在")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "mobile", dataType = "String", required = true, value = "用户手机号码"), })
    @PostMapping("/existMobile")
    Response<Boolean> existMobile(@RequestParam("mobile")
                                  @Size(min = 11, max = 11, message = "手机长度11位！")
                                  @NotBlank(message = "手机号不能为空！") String mobile);

    @ApiOperation(value = "会员登录接口")
    @PostMapping("/login")
    Response<UserLoginRespDto> login(@RequestBody @Valid UserLoginReqDto userLoginReqDto) throws Exception;

    @ApiOperation(value = "QQ会员登录接口")
    @PostMapping("/bindloginByQQ")
    Response<UserLoginRespDto> bindloginByQQ(@RequestBody @Valid QQBindLoginReqDto qqBindLoginReqDto) throws Exception;

    @ApiOperation(value = "QQ会员自动登录接口")
    @PostMapping("/autoLoginByQQ")
    Response<UserLoginRespDto> autoLoginByQQ(@RequestBody @Valid QQAutoLoginReqDto qqAutoLoginReqDto) throws Exception;

    @ApiOperation(value = "根据token查询用户接口")
    @PostMapping("/loginBytoken")
    @ApiImplicitParam(paramType = "query", name = "token", dataType = "String", required = true, value = "用户token")
    Response<UserLoginRespDto> loginBytoken(@RequestParam("token")
                                            @Min(1)
                                            @NotBlank(message = "token不能为空！") String token);

    @ApiOperation(value = "退出登录接口")
    @PostMapping("/loginout")
    @ApiImplicitParam(paramType = "query", name = "token", dataType = "String", required = true, value = "用户token")
    Response<Boolean> loginout(@RequestParam("token")
                                            @Min(1)
                                            @NotBlank(message = "token不能为空！") String token) throws Exception;

    @ApiOperation(value = "会员sso登录接口")
    @PostMapping("/loginBySSO")
    Response<UserLoginRespDto> loginBySSO(@RequestBody @Valid UserSSOLoginReqDto userSSOLoginReqDto);

}
